import 'package:flutter/material.dart';

import '../../foundation/style/bold_text_style.dart';
import '../../foundation/style/medium_text_style.dart';
import '../check_box/public_check_box.dart';
import 'horizontal_item.dart';

/// FileName check_box_item
///
/// @Author lax
/// @Date 2023/3/17
///
/// @Description

enum CheckboxPosition {
  left,
  right,
}

class CheckBoxItem extends HorizontalItem {
  CheckBoxItem({
    super.key,
    super.onTap,
    super.padding,
    String? title,
    bool? value,
    bool enable = true,
    int? maxLines,
    TextStyle? titleStyle,
    TextStyle? unableTitleStyle,
    CheckboxPosition? checkboxPosition = CheckboxPosition.right,
    Widget? child,
  }) : super(
          leftWidget: checkboxPosition == CheckboxPosition.left
              ? PublicCheckBox(value: value, enable: enable, size: 24)
              : null,
          titleWidget: Text(
            title ?? '',
            style: enable
                ? (titleStyle ??
                    HorizontalItem.defaultTitleStyle ??
                    BoldTextStyle())
                : (unableTitleStyle ??
                    HorizontalItem.defaultUnableTitleStyle ??
                    MediumTextStyle()),
            maxLines: maxLines,
            overflow: (maxLines ?? 0) > 0 ? TextOverflow.ellipsis : null,
          ),
          rightWidget: checkboxPosition == CheckboxPosition.right
              ? PublicCheckBox(value: value, enable: enable, size: 24)
              : null,
        );
}
